package com.aestheticshare.main;

import android.graphics.PorterDuff;
import android.os.Environment;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageButton;

public class Utils {
    
	public static final int REQUEST_CODE_AUTH = 1;
	
	public static final String URL_BASE_EXTERNAL_STORAGE = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) ? "file://" + Environment.getExternalStorageDirectory() + "/" : null;
	public static final String URL_BASE_ASSETS = "file:///android_asset/";
	public static final String URL_BASE_SERVER = "http://mapbb.net/";
//	public static final String URL_BASE_SERVER = "http://192.168.1.101/";

	public static final String URL_AUTH_FACEBOOK = URL_BASE_SERVER + "auth/facebook";
	public static final String URL_AUTH_TWITTER = URL_BASE_SERVER + "auth/twitter";
	
	public static final String KEY_INTRO_PAGE_POSITION = "intro_page_position";
	
	public static final int DEFAULT_IMAGE_BUTTON_ONCLICK_EFFECT_COLOR = 0xffbbbbbb;
	public static int image_button_onclick_effect_color = DEFAULT_IMAGE_BUTTON_ONCLICK_EFFECT_COLOR;
	
	public static final View.OnTouchListener IMAGE_BUTTON_ONCLICK_EFFECT_TOUCH_LISTENER = new View.OnTouchListener(){
		@Override
		public boolean onTouch(View v, MotionEvent event) {
			if(event.getAction() == MotionEvent.ACTION_DOWN){
				((ImageButton)v).setColorFilter(image_button_onclick_effect_color, PorterDuff.Mode.MULTIPLY);				
			}else if(event.getAction() == MotionEvent.ACTION_UP){
				((ImageButton)v).clearColorFilter();		
			}
			return false;
		}
		
	};
	
	public static final void log(String... msg){
		Throwable ex = new Throwable();
	    StackTraceElement[] stackElements = ex.getStackTrace();

	    if(stackElements != null && stackElements.length > 1){
        	StringBuffer sb = new StringBuffer();
        	String className = stackElements[1].getClassName();
        	sb.append(className.substring(className.lastIndexOf('.') + 1))
        	  .append('.')
        	  .append(stackElements[1].getMethodName())
        	  .append(':');
        	for(String m : msg){
        		sb.append("\n").append(m);
        	}        	
	    	Log.i("utils", sb.toString());
	    }
	}
}
